package com.baiyangtx.lingerweather.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.baiyangtx.lingerweather.R;
import com.baiyangtx.lingerweather.model.CityBasicImformation;

public class CityMangeButton extends RelativeLayout {

	
	private CityBasicImformation cityInformation = null ;
	
	
	public CityMangeButton(Context context) {
		super(context) ;
		LayoutInflater.from(context).inflate(R.layout.city_mange_button , this , true ) ;
	}
	
	
	public CityMangeButton(Context context, AttributeSet attrs) {
		super(context, attrs);
		LayoutInflater.from(context).inflate(R.layout.city_mange_button , this , true ) ;
	}

	
	@SuppressLint("DefaultLocale")
	public void setCityInformation(CityBasicImformation information){
		this.cityInformation = information ;
		TextView cityName = (TextView)findViewById(R.id.citybtn_cityname);
		TextView cityTemperature = (TextView)findViewById(R.id.citybtn_citytemperature ) ;
		ImageView cityWeather = (ImageView)findViewById(R.id.citybtn_cityweather) ;
		
		
		String temperature = String.format("%d℃", information.getCityTemperature() );
		cityTemperature.setText(temperature);
		cityName.setText(information.getCityName());
		cityWeather.setImageDrawable(information.getCityWeather()) ;	
	}
	
	public CityBasicImformation getCityInformation(){
		return cityInformation ;
	}
	
	
}
